package com.example.demo.pojo.dto;

import com.example.demo.enumeration.Campus;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.validator.constraints.Length;

@Getter
@Setter
@ToString
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public class RegisterDTO {
    @NotBlank(message = "手机号码不能为空")
    @Pattern(regexp = "^1[0-9]{10}$", message = "手机号码格式错误")
    private String phone;

    @NotBlank(message = "用户名不能为空")
    @Length(min = 1, max = 20, message = "名称长度限定为1-20个字符")
    private String name;

    @NotBlank(message = "密码不能为空")
    @Length(min = 6, max = 20, message = "密码长度限定为6-20个字符")
    private String password;

    @NotBlank(message = "学号不能为空")
    private String studentId;

    @NotNull(message = "校区不能为空")
    private Campus campus;

    @NotBlank(message = "验证码不能为空")
    @Pattern(regexp = "^[0-9]{4}$", message = "验证码为4位纯数字")
    private String code;

    public RegisterDTO() {
    }

    public RegisterDTO(String phone, String name, String password, String studentId, Campus campus, String code) {
        this.phone = phone;
        this.name = name;
        this.password = password;
        this.studentId = studentId;
        this.campus = campus;
        this.code = code;
    }
}
